#region Usings
using System.Linq;
using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.Repositories.EF
{
	public class BestExpensesRepository : BaseRepository<BestExpense>, IBestExpensesRepository, IExpensesRepository<BestExpense>
	{
		#region IBestExpensesRepository Members
	    public BestExpensesRepository(BkDataContext dataContext) : base(dataContext)
	    {
	    }

	    public BestExpense GetFirstUnprocessed()
		{
			BestExpensesRepository bestExpensesRepository = new BestExpensesRepository(Context);

			BestExpense result = (from bestExpense in bestExpensesRepository.ObjectSet
			                      where bestExpense.Processed == false
			                      select bestExpense).FirstOrDefault();

			return result;
		}

		public BestExpense[] GetAllUnprocessed()
		{
			BestExpense[] bestExpenses = (from bestExpense in ObjectSet
			                              where bestExpense.Processed == false
			                              select bestExpense).ToArray();
			return bestExpenses;
		}
		#endregion
	}
}